﻿@model Blog.Models.ArticleDetailsViewModel
@using Blog.Models

@{
    ViewBag.Title = "Details";

    int accordionNumber = 0;
    string classDiv = "";
}

<div class="container">
    <h2>@ViewBag.Message</h2>
    <h3>@Model.Article.Title : </h3><hr /><br />

    <p>
        <strong>Titre : </strong>
        @Html.DisplayFor(model => model.Article.Title)
    </p>

    <p>
        <strong>Date :</strong>
        @Html.DisplayFor(model => model.Article.Date)
    </p>

    <p>
        <strong>Catégorie :</strong>
        @Html.ActionLink(Model.Article.Category.Name, "../Categories/Details/" + Model.Article.Category.ID)
    </p>

    <p>
        <strong>Contenu :</strong>
        <div class="well">@Html.DisplayFor(model => model.Article.Content)</div>
    </p>

    <p>
        <link rel="canonical" href="/Articles/Details/@Model.Article.ID" />
        <g:plusone size="medium"></g:plusone>
        <a href="/Articles/Details/@Model.Article.ID" class="twitter-share-button" data-lang="fr">Tweet</a>
        <fb:like href="/Articles/Details/@Model.Article.ID" send="false" layout="button_count" width="450" show_faces="false"></fb:like>
    </p>

    @if (Request.IsAuthenticated)
    {
        <a href="/Articles/Edit/@Model.Article.ID" class="btn btn-primary btn-medium"><i class="icon-pencil icon-white"></i> Editer</a>
        <a href="/Articles/Delete/@Model.Article.ID" class="btn btn-danger btn-medium"><i class="icon-trash icon-white"></i> Supprimer</a><br /><br />
    }

    @if (Model.Article.Comment.Count != 0)
    { 
        <p><strong>Les commentaires : </strong></p>
    }

    <div class="accordion" id="accordion">
        @foreach (DAL.Comment comment in Model.Article.Comment)
        {
            <div class="accordion-group">
                <div class="accordion-heading">
                    <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#@accordionNumber">
                        De @comment.Username le @comment.Date
                    </a>
                </div>
                <div id='@accordionNumber' class="accordion-body collapse in">
                    <div class="accordion-inner">
                        @if (Request.IsAuthenticated)
                        {
                            <a href="/Comments/Delete/@comment.ID"><button class="close fade">×</button></a>
                        }
                        @comment.Content
                    </div>
                </div>
            </div>
            
            accordionNumber++;
        }
    </div>
    <hr />

    <div class="alert alert-info fade in">
        <button class="close fade" data-dismiss="alert">×</button>
        <strong>Info!</strong> Tous les champs sont obligatoires.
    </div>

    @using (Html.BeginForm("Create", "Comments"))
    {
        if (Blog.Models.CaptchaValidatorAttribute.ErrorMessage != null)
        {
            classDiv = "alert alert-danger fade in";
        }
        
        else
        {
            classDiv = "alert alert-danger hide fade in";
        }
        
        <div class="@classDiv">
            <button class="close fade" data-dismiss="alert">×</button>
            <strong>Erreur!</strong> @Blog.Models.CaptchaValidatorAttribute.ErrorMessage
        </div>
        
        <h5>Prénom NOM @Html.TextBoxFor(x => x.Username)</h5>
        <h5>Commentaire @Html.TextBoxFor(x => x.Content)</h5>
    
        <div class="editor-label">Veuillez recopier les caractères</div>
        <div class="captcha">@Html.Generate()</div><br />
    
        <button class="btn btn-primary btn-medium" type="submit"><i class="icon-plus icon-white"></i> Commenter</button>
    
        @Html.HiddenFor(x => x.ArticleID)
    }

    <a href="../" class="btn btn-warning btn-medium"><i class="icon-chevron-left icon-white"></i> Revenir à la liste</a>
</div>   

<script src="@Url.Content("~/Scripts/bootstrap-transition.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/bootstrap-alert.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/bootstrap-collapse.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/bootstrap-validation.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.js")" type="text/javascript"></script>
